from aiogram import types
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.state import State, StatesGroup
from aiogram.types import InputFile

import client_kb
import sqlite_db
from create_bot import dp


class DE_FSM(StatesGroup):
    doc_type_select = State()


async def create_germany(message: types.Message, state: FSMContext):
    user_id = message.from_user.id
    await sqlite_db.sql_check_user(user_id)
    await message.answer("Выберите документ для создания", reply_markup=client_kb.kb_de)
    await DE_FSM.doc_type_select.set()


@dp.message_handler(state=DE_FSM.doc_type_select)
async def doc_type(message: types.Message, state: FSMContext):
    """Реагирование на выбранный документ и отправка примера заполнения с вызовом соответствующей функции."""
    from handlers.users.generate.de_country.de_id import id_client_first_name_input
    from handlers.users.generate.de_country.Germany_bill import (
        bill_client_first_name_input,
    )

    if message.text == "ID 🇩🇪":
        type_doc = "ID 🇩🇪"
        await sqlite_db.sql_add_country_user(message.from_user.id, "de_id")
        await state.update_data(type=type_doc)
        await dp.bot.send_photo(
            chat_id=message.from_user.id, photo=InputFile(f"./files/de_id/example.jpg")
        )
        await id_client_first_name_input(message, state)
    if message.text == "BILL 🇩🇪":
        type_doc = "BILL 🇩🇪"
        await sqlite_db.sql_add_country_user(message.from_user.id, "de_bill")
        await state.update_data(type=type_doc)
        await dp.bot.send_photo(
            chat_id=message.from_user.id,
            photo=InputFile(f"./files/de_bill/example.png"),
        )
        await bill_client_first_name_input(message, state)
    if message.text == "Назад ◀️":
        from handlers.users.menu import command_create_menu_notcallback

        await command_create_menu_notcallback(message)
